﻿package  {
	
	public class dateClass {
		
		private var time:String;
		private var date:String;
		private var d:Date;

		public function dateClass() {
			time = "";
			date = "";
		}
		
		public function getDate():String{
			d = new Date();
			
			var m:String;
			if (d.getMonth() < 10){
			 m = "0" + d.getMonth();
			}
			else{
				m = d.getMonth().toString();
			}
			
			var day:String;
			if (d.getDay() < 10){
			 day = "0" + d.getDay();
			}
			else{
				day = d.getDay().toString();
			}
			
			return d.getFullYear() + "-" + m + "-" + day;
		}
		
		public function getTime():String{
			
			var h:String;
			if (d.getHours() < 10){
			 h = "0" + d.getHours();
			}
			else{
				h = d.getHours().toString();
			}
			
			var min:String;
			if (d.getMinutes() < 10){
			 min = "0" + d.getMinutes();
			}
			else{
				min = d.getMinutes().toString();
			}
			
			var sec:String;
			if (d.getSeconds() < 10){
			 sec = "0" + d.getSeconds();
			}
			else{
				sec = d.getSeconds().toString();
			}
			
			return h + ":" + min + ":" + sec;

		}
		
		public function compareDateTime(se:String, sl:String){
			
			trace(se);
			trace(sl + "from db");
			
			//Opsplitsen van 2011/04/30 13:34:34 in een datum en tijd 
			var de:String = se.substring(0, 10);
			var te:String = se.substring(11,int.MAX_VALUE);
			var dl:String = sl.substring(0, 10);
			var tl:String = sl.substring(11,int.MAX_VALUE);
			
			trace(de);
			trace(te);
			trace(dl);
			trace(tl);
			
			if (sl == "null"){
				return true;
				trace("Update");
			}
			else{
			if ((dl <= de) && (tl < te)) {
				return true;
				trace("Updaten!");
			}
			else{
				return false;
				trace("Geen Update");
			}
			}
		}

	}
	
}
